<form id="form">
<div class="modal-header">
	<button type="button" class="close" data-dismiss="modal">
		<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
	</button>
	<small class="modal-title">
	<#if ids?split(",")?size gt 1>
	<i class="fa fa-pencil"></i> 批量编辑商家主页
	<#else>
	<i class="fa fa-pencil"></i> 编辑商家主页-${model.business_name}
	</#if>
	</small>
</div>
<div class="modal-body" style="height:330px;overflow-y:auto;">
	<div class="tabs-container">
		<div class="form-horizontal clearfix">
			<input type="hidden" name="ids" value="${ids}"/>
			<div class="col-sm-12">
				<div class="form-group">
                    <label class="col-sm-4 control-label">选择欢迎语的内容</label>
                    <div class="col-sm-8">
                    	<div class="radio radio-primary">
                                <input type="radio" value="0" <#if (model?? && model.bar_type?? && model.bar_type == 0) || !model?? || !model.bar_type??>checked</#if> id="bar1" name="bar_type"/> <label for="bar1">欢迎光临+公众号名称!</label>
                        </div>
                        <div class="radio radio-primary">
                                <input type="radio" value="1" <#if model?? && model.bar_type?? && model.bar_type == 1>checked</#if> id="bar2" name="bar_type"> <label for="bar2">欢迎光临+门店名称!</label>
                        </div>
                        <div class="radio radio-primary">
                                <input type="radio" value="2" <#if model?? && model.bar_type?? && model.bar_type == 2>checked</#if> id="bar3" name="bar_type"> <label for="bar3">已连接+公众号名称+Wi-Fi!</label>
                        </div>
                         <div class="radio radio-primary">
                                <input type="radio" value="3" <#if model?? && model.bar_type?? && model.bar_type == 3>checked</#if> id="bar4" name="bar_type"> <label for="bar4">已连接+门店名称+Wi-Fi!</label>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-4 control-label">自定义链接</label>
                    <div class="col-sm-8">
                    	<input type="text" id="homepage" name="homepage" value="<#if model??>${model.homepage!''}</#if>" class="form-control requiredIcon" placeholder="请输入http://或者https:开头自定义链接">
                    </div>
                </div>
			</div>
		</div>
	</div>
</div>
<div class="modal-footer">
	<button class="btn btn-white" data-dismiss="modal">关闭</button>
	<button class="btn btn-primary" type="submit">保存</button>
</div>
</form>
<script>
$(function(){
	var validator = $("#form").validate({
          ignore: ".ignore",
      	  rules: {
                homepage: {
                    required: true,
                    url: true
                }
            },
            messages: {
            	homepage: {
                    required: icon + "请输入自定义链接",
                    url: icon + "需使用http://或者https://开头"
                }
            },
            submitHandler: function(form){
            	//显示loading提示
                var loading = layer.load();
                $(form).ajaxSubmit({
               		url:"${basePath}/wxstore/homepage",
               	 	type:"POST",
               	 	dataType:"json",
               	 	success: function (resp) {
               	 		layer.close(loading);
	            		if(resp.code == 0) {
	            			$("#homepageModal").modal("hide");
    	            		swal({
    	                  		title: "操作成功",
    	                  		type: "success",
    	                  		showCancelButton: false,
    	                  		confirmButtonColor: '#18a689',
    	                  		confirmButtonText: '确定',
    	                  		closeOnConfirm: true
    	                  	},
    	                  	function(){
    	                  		$("#table").bootstrapTable("refresh");
    	                  	});
	            		}else if(resp.code == 1){
	            			swal("操作失败！", resp.data, "error");
	            		}else {
	            			swal("操作失败！", "未知错误", "error");
	            		}
                 	}
                });
            },
            showErrors: function(errorMap, errorList) {
          		this.defaultShowErrors();
            }
        });
})
</script>

